<?php

namespace postController;

require_once 'model/PrintPictures.php';
require_once 'view/LogInPage.php';
require_once 'model/LogInModel.php';
require_once 'view/ViewPost.php';
require_once 'model/DatabaseFunctions.php';
require_once 'model/Uploadpic.php';

class PostController{
	private $viewlogInPage;
	private $viewPost;
	private $model;
	private $dbFunctions;
	private $uploadPic;
	
	public function __construct(){
		$this->viewlogInPage = new \logInPage\LogInPage();
		$this->model = new \logInModel\LogInModel();
		$this->viewPost = new \viewPost\ViewPost();
		$this->dbFunctions = new \databaseFunctions\DatabaseFunctions();
		$this->uploadPic = new \uploadPic\UploadPic();
	}
	
	//@return string (table/pics and comments)
	public function printControl(){
		if($this->model->checkIfLoggedIn()){
				$table = $this->viewPost->postPictures();
			return $table;
			}
		return $table = "";	
		}	
	
	//gets everything to create comment in model
	public function createComments(){
		$pictureId = $this->viewlogInPage->getbuttonValue();
		$user = $this->model->getUsername();
		$comments = $this->viewlogInPage->getComments();
		$this->dbFunctions->saveComments($pictureId, $user, $comments);
	}
	
	//gets everything to delete comment in model
	public function deleteComments(){
		$unique= $this->viewlogInPage->getUnique();
		$this->dbFunctions->commentDelete($unique);
	}
	//gets everything to delete image
	public function deleteImages(){
		$value= $this->viewlogInPage->deleteImgValue();
		$this->dbFunctions->ImgDelete($value);
		$this->uploadPic->deleteImg($value);
	}
	
	//gets everything to edit comment in model
	public function editComment(){
		$newComment = $this->viewlogInPage->getnewComment();
		$editId = $this->viewlogInPage->getEditId();
		$this->dbFunctions->fixComment($editId, $newComment);
	}
}






